
function show_send(){
	var msg_box = $("#msg-box");
	msg_box.dialog({
		title:'发私信',
		modal:true,
		resizable:false,
		height:300,
		width:500, 
		buttons: {
			"发送": function() {
				var recv = $("#msg-recv").val();
				var text = $("#msg-text").val();    
				var res = check_recv(recv);
				if(res==404){
					alert(recv+" 不存在！");
					return false;
				}
				if(res==403){
					alert(recv+" 没跟随您，还不能给他发私信！");
					return false ;
				} 
				$.post('/msg/send_one',{'text':text,'to_uid':recv},function(data){
				});
				$( this ).dialog( "close" );
				
			},
			"取消": function() {
				$( this ).dialog( "close" );
			}
		}
	}); 
}

function send_msg(){ 
	var recv = $("#msg_nick").attr('title');
	var text = $("#msg_editor").val();  
	var res = check_recv(recv);
	if(res==404){
		alert(recv+" 不存在！");
		return false;
	}
	if(res==403){
		alert(recv+" 没跟随您，还不能给他发私信！");
		return false ;
	} 
	$.post('/msg/send_one',{'text':text,'to_uid':recv},function(data){
		$("#msg_list").prepend(data);
	});
	return true;
}
function destroy_msg(msgid){
	$.post('/msg/destroy_msg',{'msgid':msgid},function(result){
		if(result==true){
			$("#"+msgid).remove();
		}
	});
}
function check_recv(uid){
	var res = 200;
	$.ajax({
		type:'GET',
		url:"/check_receiver",
		data:{'recv':uid},
		async: false,
		success: function(data){
			res = data;
		}
	});
	
	return res;
} 